import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AgreementVO, AgreementForm, AgreementQuery } from '@/api/tearoom/agreement/types';

/**
 * 查询协议描述列表
 * @param query
 * @returns {*}
 */

export const listAgreement = (query?: AgreementQuery): AxiosPromise<AgreementVO[]> => {
  return request({
    url: '/tearoom/agreement/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询协议描述详细
 * @param id
 */
export const getAgreement = (id: string | number): AxiosPromise<AgreementVO> => {
  return request({
    url: '/tearoom/agreement/' + id,
    method: 'get'
  });
};

/**
 * 新增协议描述
 * @param data
 */
export const addAgreement = (data: AgreementForm) => {
  return request({
    url: '/tearoom/agreement',
    method: 'post',
    data: data
  });
};

/**
 * 修改协议描述
 * @param data
 */
export const updateAgreement = (data: AgreementForm) => {
  return request({
    url: '/tearoom/agreement',
    method: 'put',
    data: data
  });
};

/**
 * 删除协议描述
 * @param id
 */
export const delAgreement = (id: string | number | Array<string | number>) => {
  return request({
    url: '/tearoom/agreement/' + id,
    method: 'delete'
  });
};
